/**
 * This is just <%= whatIsThis %>.
 *
 * You can use underscore templates, see?
 */
var util = require('util');
var _ = require('lodash');
_.defaults = require('merge-defaults');
var fs = require('fs');
var path = require('path');
_.str = require('underscore.string');


module.exports = {
  homePage: function () {
    return this.compiled('homePageEJS');
  },

  compiled: function (file, data) {
    data = data || {};
    var tableDataPath = path.resolve(__dirname, './' + file + '.template');
    var template = fs.readFileSync(tableDataPath, 'utf8');

    var compiledEJS = _.template(template, {});
    var compiled = (compiledEJS(data))

    // This puts erb style delimeters
    compiled = _.replace(compiled, /ERBstart=/g, '<%=');
    compiled = _.replace(compiled, /ERBstart/g, '<%');
    compiled = _.replace(compiled, /ERBend/g, '%>');

    return compiled;
  }

}
